package com.itheima.sh.dao;

import com.itheima.sh.pojo.Contact;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ContactMapper {
    //测试查询所有
    @Select("select * from contact")
    List<Contact> findAllContact();

    //登录用户
    @Select("select * from contact where name=#{name} and password=#{password}")
    Contact loginContact(@Param("name") String name, @Param("password") String password);

    //添加用户
    @Insert("insert into contact values(null,#{name},#{password},#{sex},#{age},#{address},#{qq},#{email})")
    Integer  registerContact(Contact c);

    //修改时根据ID回显
    @Select("select * from contact where  id=#{id}")
    Contact findContactById(Integer id);

    //用户修改
    @Update("update contact set name=#{name},password=#{password},sex=#{sex},age=#{age},address=#{address},qq=#{qq},email=#{email} where id=#{id}")
    Integer updateContact(Contact contact);

    //删除用户
    @Delete("delete  from contact where id=#{id}")
    Integer deleteContactById(Integer id);
}
